ActionController::Routing::Routes.draw do |map|
  #Named Routes
  map.login 'login', :controller => :user_sessions, :action => :new
  map.logout 'logout', :controller => :user_sessions, :action => :destroy
  map.reset_password 'reset_password', :controller => :password_resets, :action => :new
  map.activate '/activate/:activation_code/', :controller => :activations, :action => :create
  map.search 'search', :controller => :searches, :action => :show
  map.random_article 'random_article', :controller => :home, :action => :random
  map.add_favorite 'add_favorite', :controller => :favorites, :action => :create
  map.remove_favorite 'remove_favorite', :controller => :favorites, :action => :destroy

  #Resources
  map.resources :reviews
  map.resources :name_aliases
  map.resources :artist_dates
  map.resources :membership_dates
  map.resources :song_dates
  map.resources :edition_dates
  map.resources :label_dates
  map.resources :delete_requests
  map.resources :user_sessions
  map.resources :users, :collection => { :resend_activation => :get }
  map.resources :password_resets, :collection => { :admin_create => :get }
  map.resource :admin
  map.resources :select_search, :collection => {:search => :get}, :only => [:new, :create]
  map.resources :forums
  map.resources :forum_threads
  map.resources :posts

  #Nested Resources
  map.resources :labels do |label|
    label.resources :edits
  end

  map.resources :genres do |genre|
    genre.resources :edits
  end

  map.resources :artists, :member => { :release_set => :get} do |artist|
    artist.resources :memberships,
                   	 :shallow => true,
					 :collection => { :search => :get }
    artist.resources :edits
    artist.resources :images
    artist.resources :genre_links,
	                 :collection => { :search => :get },
                   	 :only => [:new, :create, :destroy]
  end

  map.resources :releases do |release|
    release.resources :editions do |edition|
      edition.resources :images
	  edition.resources :discs,
         	            :shallow => true
    end
	
    release.resources :artist_links,
					  :only => [ :new, :create ],
                	  :collection => { :search => :get, :remove => :delete }
    release.resources :edits
  end

  map.resources :editions do |edition|
    edition.resources :images
    edition.resources :edition_credits,
                      :shallow => true, 
					  :collection => { :search => :get }
					  
    edition.resources :genre_links,
	                  :collection => { :search => :get },
                 	  :only => [:new, :create, :destroy]
					  
	edition.resources :label_links,
	                  :collection => { :search => :get },
                  	  :only => [:new, :create, :destroy]
  end

  map.resources :songs do |song|
    song.resources :artist_links,
	               :only => [ :new, :create ],
	               :collection => { :search => :get, :remove => :delete }
				   
    song.resources :song_credits,
                   :shallow => true,
				   :collection => { :search => :get }
				   
    song.resources :song_collections,
	               :only => [:new, :create],
				   :collection => { :search => :get }
				   
    song.resources :edits
    song.resources :genre_links,
	               :collection => { :search => :get },
	               :only => [:new, :create, :destroy]
  end

  #Will delete these soonish
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'

  #Root http://www.temdb.com/
  map.root :controller => :home, :action => :index
end
